package com.xzg.myMission.server;

import com.xzg.common.page.PageQueryBean;
import com.xzg.common.vo.QueryCondition;
import com.xzg.myMission.dao.MyMissionMapper;
import com.xzg.myMission.entity.MyMission;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class MyMissionServiceImpl implements MyMissionService {

    @Autowired
    private MyMissionMapper myMissionMapper;

    @Override
    public PageQueryBean findAllMission(QueryCondition condition) {
        //记录数目
        int count = myMissionMapper.countByCondition(condition);
        PageQueryBean pageResult = new PageQueryBean();
        if (count > 0) {
            pageResult.setTotalRows(count);
            pageResult.setCurrentPage(condition.getCurrentPage());
            pageResult.setPageSize(condition.getPageSize());
            List<MyMission> missionList = myMissionMapper.partMission(condition);
            pageResult.setItems(missionList);
        }
        return pageResult;
    }

    @Override
    public MyMission findOne(Long missionId) {
        return null;
    }
}
